package com.yuanfeng.activity.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yuanfeng.activity.entity.ActivitySpinwinPrizeEntity;
import com.yuanfeng.activity.mapper.ActivitySpinwinPrizeMapper;
import com.yuanfeng.activity.service.ActivitySpinwinPrizeService;
import com.yuanfeng.activity.vo.SpinwinPrizeListVO;
import com.yuanfeng.commoms.exception.BizCodeEnume;
import com.yuanfeng.commoms.util.ParseTokenUtils;
import com.yuanfeng.commoms.util.ResponseResult;
import com.yuanfeng.commoms.vo.user.UserInfoVO;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 *
 */
@Service
public class ActivitySpinwinPrizeServiceImpl extends ServiceImpl<ActivitySpinwinPrizeMapper, ActivitySpinwinPrizeEntity>
    implements ActivitySpinwinPrizeService{

    @Override
    public ResponseResult deleteSpinwinPrize(Map<String, Object> param) {
        this.baseMapper.deleteById(param.get("prizeId").toString());
        return ResponseResult.success(BizCodeEnume.OPERATION_SUCCESSFUL);
    }

    @Override
    public ResponseResult updateSpinwinPrize(Map<String, Object> param) {
        UserInfoVO userInfo = ParseTokenUtils.getPlatformUser(param.get("token").toString());

        param.put("updateBy",userInfo.getUserRealname());
        param.put("updateDate",new Date());
        if (null == param.get("prizeId")|| param.get("prizeId")=="") {
            this.baseMapper.insertSpinwinPrize(param);
        } else {
            this.baseMapper.updateSpinwinPrize(param);
        }

        return ResponseResult.success(BizCodeEnume.OPERATION_SUCCESSFUL);
    }

    @Override
    public ResponseResult querySpinwinPrizeList(Map<String, Object> param) {
        List<SpinwinPrizeListVO> list=this.baseMapper.selectSpinwinPrizeList(param);
        return ResponseResult.success(list);
    }


}




